<?php
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/user/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/tucao/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/mblog/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/taobao/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/tuijian/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/config/city_config.php");

//所有的参数
$g_cgival 	= array();
//存储中间数据 非输出数据 可以不用
$g_pro	 	= array();
//要显示的数据 输出数据
$g_show 	= array();

function check_cgi_pro()
{		
	global $g_cgival, $g_pro, $g_show, $config;
	
	cgi::both($g_cgival["p"], "p", "");
	$g_cgival["p"] = intval($g_cgival["p"]);
	
	if($g_cgival["p"] < 1) $g_cgival["p"]=1;

	
	cgi::both($g_cgival["tag_id"], "tag_id", "");
	$g_cgival["tag_id"] = intval($g_cgival["tag_id"]);
	
	cgi::both($g_cgival["show_type"], "show_type", "");
	$g_cgival["show_type"] = intval($g_cgival["show_type"]);
	
	cgi::both($g_cgival["id"], "id", "");
	$g_cgival["id"] = intval($g_cgival["id"]);
}


function get_data()
{
	
	global $g_cgival, $g_pro, $g_show, $config;
	$g_show["id"] = $id = $g_cgival["id"] ;
	$g_show["main_domain"] = "http://".$config["main_domain"];
	$p = $g_cgival["p"];
	$pcount = $g_cgival["pcount"] =20;
	
	$start_year = "2013";
	$get_weeks = ceil((time()-strtotime("$start_year-01-01"))/(86400*7));


	
	//登录相关
	$user_info = new user_info();
	$is_login = $user_info->is_logined();
	
	if($is_login)
	{
		$user_detail_info = $user_info->get_cur_user_info();
	
		$uid = $user_detail_info["uid"];
		$user_nickname = $user_detail_info["user_nickname"];
		$g_show["is_logined"] = true;
		$g_show["current_user_info"] = $user_detail_info;
		$config["show_pubu"] = true;
	}
	//登录
	
	
	//关键字
	$db_mblog_cron_topic_tag = new db_mblog_cron_topic_tag();
	$current_site_name = $config["current_site_name"];
	$g_show["page_keywords"]  = "{$current_site_name},{$current_site_name}图片,{$current_site_name}视频,{$current_site_name}组队,{$current_site_name}玩家,一起玩{$current_site_name},玩{$current_site_name},玩{$current_site_name}的人";
	$g_show["page_desc"]  = "{$current_site_name}玩家分享的游戏美图,{$current_site_name}玩家聚集地";
	$g_show["page_title"] = "{$current_site_name}美图_游戏美图";
	$g_show["page_desc"]  .=  "_最有意思的游戏玩家分享平台";	
	//关键字
	
	//导航配置
	$daohang[] = "<a href='/mblog/'>图库</a>";
	if($current_tag_info["tag_name"])
	{
		$daohang[] = $current_tag_info["tag_name"];
	}
	else
	{
		$daohang[] = "首页";
	}
	$g_show["daohang"] =join(" <i>&gt;</i> ",$daohang);
	//导航配置

	//取数据
	$db_tuijian_daren = new db_tuijian_daren();
	$g_show["tuijian_user_info"] = $db_tuijian_daren->get_item_by_id($id);
	
	$g_show["count"] = $count = $db_tuijian_daren->get_count_by_max_id($get_weeks);
	$list = $db_tuijian_daren->get_list_by_order($g_cgival["p"],$g_cgival["pcount"],$get_weeks);
	foreach($list as $key =>$value)
	{
		$list[$key]["detail_info"] = unserialize($value["detail_info"]);
		$list[$key]["detail_info"]["main_topic"] = $config['site_name'][$list[$key]["detail_info"]["main_topic_id"]];
		$list[$key]["detail_info"]["head_url"]= str_replace("/50/","/180/",$list[$key]["detail_info"]["head_url"] );
		
		$list[$key]["detail_info"]["province_name"] = $config['province'][$list[$key]["detail_info"]["province"]]["name"];
		$list[$key]["detail_info"]["city_name"] = $config['city'][$list[$key]["detail_info"]["province"]][$list[$key]["detail_info"]["city"]];
		$old = date("Y")-$list[$key]["detail_info"]["birthyear"];
		if($old < 200){
		$list[$key]["detail_info"]["old"] =$old  ;
		}
		
	}
	
	$g_show["list"] = $list ;
	$Pages = new Pages($g_show["count"],$g_cgival["p"],$g_cgival["pcount"]);
	$g_show["page_bar"] = $Pages->getLinks_static("/tuijian/index_replacepage.html",8);
	
	
}

try {
	$g_show['error'] = 0;
	$g_show['errmsg'] = "";
	check_cgi_pro();
	get_data();
	
} catch (Exception $e) {
	$g_show['error'] = 1;
	$g_show['errmsg'] = $e->getMessage();
}

show_pro();


exit;

function show_pro()
{
	global $g_cgival, $g_pro, $g_show, $config;

	$smarty = p_get_smarty();	
	$smarty->assign("g_show", $g_show);
	if (isset($_GET["debug"]))
	{
		print_r($g_show);
	}
	$smarty->display("tuijian/user_list.html");
	
	unset($g_cgival);
	unset($g_pro);
	unset($g_show);
	unset($config);
	
}

